/*
 *  NOWAI.cpp
 *  TubeTruck
 *
 *  Created by Aeturnum on 6/5/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#include "NOWAI.h"

using namespace std;
using namespace TTP; 

NOWAI::NOWAI() : Packet(Packet_NOWAI)
{}
NOWAI::NOWAI(id_hash& idHash) : Packet(idHash)
{}
NOWAI::~NOWAI() {}

// idHash
void NOWAI::setDestIdHash(id_hash idHash) {
   mIdHash = idHash;
}

id_hash NOWAI::getDestIdHash() const {
   return mIdHash;
}

void NOWAI::fromVec(vector<byte>::const_iterator &vit, vector<byte>::const_iterator &end) {
   Packet::fromVec(vit, end);
   hashFromVec(vit);
   if(!verifyHash()) {
      throw msg_exception("NOWAI packet failed consistancy check.");
   }
}
void NOWAI::toVec(vector<byte> &vec) const {
   createHash();
   Packet::toVec(vec);
   hashToVec(vec);
}

vector<byte> NOWAI::getHashablePacket() const {
   vector<byte> vec;
   vector<byte> fakeHash(getBlankHash());
   
   Packet::toVec(vec);
   vec.insert(vec.end(), fakeHash.begin(), fakeHash.end());
   return vec;
}